import { request } from 'umi';

export async function getSubDeptListByPage({ current, pageSize, ...params }: PERMISSIONSAPI.SubDeptQueryParams) {
    return request(`/api/bui/sub/dept/${current}/limit/${pageSize}`, {
        method: 'GET',
        params
    });
}

export async function addSubDept(obj: Partial<PERMISSIONSAPI.SubDept>) {
    return request(`/api/bui/sub/dept`, {
        method: 'POST',
        data: obj
    });
}

export async function editSubDept({ sub_dept_code, ...obj }: Pick<PERMISSIONSAPI.SubDept, 'sub_dept_code'> & Partial<Omit<PERMISSIONSAPI.SubDept, 'sub_dept_code'>>) {
    return request(`/api/bui/sub/dept/${sub_dept_code}`, {
        method: 'PATCH',
        data: obj
    });
}

export async function deleteSubDept(sub_dept_code: PERMISSIONSAPI.SubDept['sub_dept_code']) {
    return request(`/api/bui/sub/dept/${sub_dept_code}`, {
        method: 'DELETE'
    });
}
